import { AxiosRequestConfig, AxiosResponse } from "axios";

export interface HFRequestInterceptors<T = AxiosResponse> {
	requestInterceptor?: (config: AxiosRequestConfig) => AxiosRequestConfig; // 请求拦截类型
	requestInterceptorCatch?: (err: any) => any; // 请求拦截错误类型
	responseInterceptor?: (config: T) => T; // 响应拦截类型
	responseInterceptorCatch?: (err: any) => any; // 响应拦截错误类型
}

export interface HFRequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
	interceptors?: HFRequestInterceptors<T>;
}

// * 请求响应参数(不包含data)
export interface Result {
	code: number;
	msg: string;
}

// * 请求响应参数(包含data)
export interface ResultData<T = any> extends Result {
	data?: T;
}

// * 分页响应参数
export interface ResPage<T> {
	datalist: T[];
	pageNum: number;
	pageSize: number;
	total: number;
}

// * 分页请求参数
export interface ReqPage {
	pageNum: number;
	pageSize: number;
}

// * 登录
export namespace Login {
	export interface ReqLoginForm {
		username: string;
		password: string;
	}

	export interface ResLogin {
		token: string;
		nickname: string;
	}

	export interface ResAuthButtons {
		[propName: string]: any;
	}
}
